import { createI18n } from 'vue-i18n'
import Cookies from 'js-cookie'

import en from './locales/en';
import cn from './locales/cn';

const message = {
  cn,
  en
}

// get Cookie
// const Cookies = useCookie('lang', {
//   maxAge: 1000 * 60
// })
// // Set Cookie
// Cookies.value = Cookies.value || 'cn'

// // Delete Cookie
// cookie.value = undefined



const i18n = createI18n({
  legacy: false,
  globalInjection: true,
  fallbackLocale: 'cn',
  locale: Cookies.get('lang') || 'cn',
  warnHtmlMessage: false,
  messages: message
})

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(i18n);
})